From e97d12ad95b22d60cdf4db35f3cd524c3170f9ca Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Sun, 28 Nov 2004 08:54:57 +0000 Subject: [PATCH] bitkeeper revision 1.1159.187.27 (41a99261iejadhs-BVt7TOiimzafww) Fix IOPL handling. 1. Both Linux 2.4 and 2.6 were not correctly setting IOPL during context switch (they sent a bogus dom0_op with a bad version number). 2. The switch_vm86 hypercall was corrupting EFLAGS and setting IOPL==0. --- linux-2.4.28-xen-sparse/arch/xen/kernel/process.c | 1 + .../arch/xen/i386/kernel/process.c | 1 + xen/arch/x86/x86_32/entry.S | 12 ++++++------ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/linux-2.4.28-xen-sparse/arch/xen/kernel/process.c b/linux-2.4.28-xen-sparse/arch/xen/kernel/process.c index f2e32dcfd4..ad7e82dc79 100644 --- a/linux-2.4.28-xen-sparse/arch/xen/kernel/process.c +++ b/linux-2.4.28-xen-sparse/arch/xen/kernel/process.c @@ -344,6 +344,7 @@ void fastcall __switch_to(struct task_struct *prev_p, struct task_struct *next_p op.cmd = DOM0_IOPL; op.u.iopl.domain = DOMID_SELF; op.u.iopl.iopl = next->io_pl; + op.interface_version = DOM0_INTERFACE_VERSION; queue_multicall1(__HYPERVISOR_dom0_op, (unsigned long)&op); } diff --git a/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/process.c b/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/process.c index 1552e00db7..aabca9cba1 100644 --- a/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/process.c +++ b/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/process.c @@ -534,6 +534,7 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas op.cmd = DOM0_IOPL; op.u.iopl.domain = DOMID_SELF; op.u.iopl.iopl = next->io_pl; + op.interface_version = DOM0_INTERFACE_VERSION; queue_multicall1(__HYPERVISOR_dom0_op, (unsigned long)&op); } diff --git a/xen/arch/x86/x86_32/entry.S b/xen/arch/x86/x86_32/entry.S index 4bfcb945d3..1befb2828d 100644 --- a/xen/arch/x86/x86_32/entry.S +++ b/xen/arch/x86/x86_32/entry.S @@ -585,8 +585,8 @@ do_switch_vm86: # Discard the return address addl $4,%esp - movl XREGS_eflags(%esp),%ecx - + movl XREGS_eflags(%esp),%edx + # GS:ESI == Ring-1 stack activation movl XREGS_esp(%esp),%esi VFLT1: movl XREGS_ss(%esp),%gs @@ -608,11 +608,11 @@ VFLT3: movl %gs:(%esi),%eax # Fix up EFLAGS andl $~X86_EFLAGS_IOPL,XREGS_eflags(%esp) - andl $X86_EFLAGS_IOPL,%ecx # Ignore attempts to change EFLAGS.IOPL + andl $X86_EFLAGS_IOPL,%edx # Ignore attempts to change EFLAGS.IOPL jnz 1f - orl $X86_EFLAGS_IF,%ecx # EFLAGS.IOPL=0 => no messing with EFLAGS.IF -1: orl $X86_EFLAGS_VM,%ecx # Force EFLAGS.VM - orl %ecx,XREGS_eflags(%esp) + orl $X86_EFLAGS_IF,%edx # EFLAGS.IOPL=0 => no messing with EFLAGS.IF +1: orl $X86_EFLAGS_VM,%edx # Force EFLAGS.VM + orl %edx,XREGS_eflags(%esp) jmp test_all_events -- 2.30.2